#include "StdAfx.h"
#include "NetOperation.h"
#include "thread.h"
#include ".\asyntcpclient.h"


CAsynTcpClient * CAsynTcpClient::m_pAsynTcpClient;

CAsynTcpClient::CAsynTcpClient(void)
:m_bIsRun(TRUE)
{
}

CAsynTcpClient::~CAsynTcpClient(void)
{
}

CAsynTcpClient * CAsynTcpClient::GetInstance()
{
	if (NULL == m_pAsynTcpClient)
	{
		m_pAsynTcpClient = new CAsynTcpClient();
	}
	return m_pAsynTcpClient;
}

LPVOID CAsynTcpClient::OnRun()
{
	while(m_bIsRun)
	{
		//ProcessMsg();
		Sleep(1000);
	}
	return NULL;
}

BOOL CAsynTcpClient::Init( const char *ip,int iPort )
{
	return m_TcpClient.Connect(ip,iPort);
}

int CAsynTcpClient::RecvMsg( char *pBuf,int iBufLen )
{
	return m_TcpClient.ReadData(pBuf,iBufLen);
}

int CAsynTcpClient::SendMsg( char *pBuf,int iMsgLen )
{
	return m_TcpClient.WriteData(pBuf,iMsgLen);
}

void CAsynTcpClient::ProcessMsg()
{
	char buf[128] = {'a',};
	memset(buf,'a',128);
	SendMsg(buf,128);
}
